;;
;; @file    le-emacs-org.el
;; @author  Gan XiangLe
;; @created 2011/11/24
;; @brief   Config the org mode in Emacs on Windows.
;;        
;; [MANAUAL INSTALL]
;;   $tar zxvf org-7.4.tar.gz 
;;   $mv org-7.4/ ~/.emacs.d/
;;   $cd ~/.emacs.d/org-7.4/
;;   $make


(defvar  ORG_WORKSPACE
  (if isWindows 
      "E:/my_sources/org_workspace"
    "/home/le/Desktop/Win7_E/my_sources/org_workspace"))  
(defvar ORG_CSS_FILE  "org_html_style_norang.css")
(defvar ORG-CSS-PATH (concat ORG_WORKSPACE "/style/" ORG_CSS_FILE))

; load path, org is included in later emacs version
;(setq load-path (cons "~/.emacs.d/org-7.4/lisp" load-path))
;(setq load-path (cons "~/.emacs.d/org-7.4/contrib/lisp" load-path))

(require 'org-install)
(require 'org-publish)

(add-to-list 'auto-mode-alist '("\\.org\\'" . org-mode))

; not needed when global-font-lock-mode is on
(add-hook 'org-mode-hook 'turn-on-font-lock 
          (lambda () (setq truncate-lines nil)) ) 

; The following lines are always needed. Choose your own keys.
; (global-set-key (kbd "<f8> p") 'org-publish)
(global-set-key "\C-cl" 'org-store-link)
(global-set-key "\C-ca" 'org-agenda)
(global-set-key "\C-cb" 'org-iswitchb)
(setq org-agenda-files (list (concat ORG_WORKSPACE "/orgs/todos/study.org")
			     (concat ORG_WORKSPACE "/orgs/todos/course.org")))

; turn on org-indent-mode(minor mode),all lines are prefixed for display 
; with the necessary amount of space.
(setq org-startup-indented t)
;; hiding all leading stars
;(setq org-hide-leading-stars t)

; [STYLE]
; Use org_**.css from local for export document stylesheets
(setq org-export-html-style-extra (concat "<link rel=\"stylesheet\" href=\""
                                          ORG-CSS-PATH
                                          "\" type=\"text/css\" />"))
(setq org-export-html-style-include-default nil)
; Do not generate internal css formatting for HTML exports
(setq org-export-htmlize-output-type (quote css))
; Inline images in HTML instead of producting links to the image
(setq org-export-html-inline-images t)

; [EXPORT]
; Disabling Underscore subscript in Emacs Tex Mode
(setq org-export-with-sub-superscripts nil)

; [PUBLISH]
(if isWindows
    (setq org-publish-project-alist
          '(("note-org"
             :base-directory       "E:/my_sources/org_workspace/orgs"
             :publishing-directory "E:/my_sources/org_workspace/htmls"
             :base-extension "org"
             :style-include-default nil
             :recursive t
             :auto-sitemap t
             :sitemap-title "Lemacs's notes"
             :sitemap-filename "index.org"
             :sitemap-alphabetically t
             :link-up "index.html"
             :link-home "index.html"
             :style-extra 
             "<link rel=\"stylesheet\" href=\"../style/org_html_style_norang.css                              
                              \" type=\"text/css\"/>"
             :publishing-function org-publish-org-to-html)
            ("note-extra"
             :base-directory        "E:/my_sources/org_workspace/orgs"
             :publishing-directory  "E:/my_sources/org_workspace/htmls"
             :recursive t
             :base-extension 
             "css\\|js\\|png\\|jpg\\|gif\\|pdf\\|mp3\\|swf\\|zip\\|gz\\|txt\\|el"
             :publishing-function org-publish-attachment
             :author nil)
            ("org" 
             :components ("note-org")
             :author "gan_xiangle"
             :email-info "ganxiangle@gmail.com"
             ))
          )
  ;; else isLinux
  (setq org-publish-project-alist
        '(("note-org"
           :base-directory       "/home/le/Desktop/Win7_E/my_sources/org_workspace/orgs"
           :publishing-directory "/home/le/Desktop/Win7_E/my_sources/org_workspace/htmls"
           :base-extension "org"
           :style-include-default nil
           :recursive t
           :auto-sitemap t
           :sitemap-title "Lemacs's notes"
           :sitemap-filename "index.org"
           :sitemap-alphabetically t
           :link-up "index.html"
           :link-home "index.html"
           :style-extra 
           "<link rel=\"stylesheet\" href=\"../style/org_html_style_norang.css                              
                              \" type=\"text/css\"/>"
           :publishing-function org-publish-org-to-html)
          ("note-extra"
           :base-directory        "/home/le/Desktop/Win7_E/my_sources/org_workspace/orgs"
           :publishing-directory  "/home/le/Desktop/Win7_E/my_sources/org_workspace/htmls"
           :recursive t
           :base-extension 
           "css\\|js\\|png\\|jpg\\|gif\\|pdf\\|mp3\\|swf\\|zip\\|gz\\|txt\\|el"
           :publishing-function org-publish-attachment
           :author nil)
          ("org" 
           :components ("note-org")
           :author "gan_xiangle"
           :email-info "ganxiangle@gmail.com"
           ))
        ))


; [KEY]
; It's bound to C-S-F12 so I just edit and hit C-S-F12 when I'm done and move on to the next thing
(defun bh/save-then-publish ()
  (interactive)
  (save-buffer)
  (org-save-all-org-buffers)
  (org-publish-all))
(global-set-key (kbd "C-<f12>") 'bh/save-then-publish)

; [DITAA IN ORG]
(setq org-ditaa-jar-path "~/Software/ditaa0_9/ditaa0_9.jar")
(add-hook 'org-babel-after-execute-hook 'org-display-inline-images)
(setq org-babel-load-languages (quote ((emacs-lisp . t)
				       (dot . t)
				       (ditaa . t)
				       (R . t)
				       (python . t)
				       (ruby . t)
				       (gnuplot . t)
				       (clojure . t)
				       (sh . t))))

(setq org-confirm-babel-evaluate nil)












